using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace SypEngine
{
    [Serializable]
    public class SypSyncAlbum
    {
        public string syncFolder = null;
        public List<string> Entities = null;

        public SypSyncAlbum(){}

    }

    [Serializable]
    public class SypSyncSite
    {
        public int siteID;
        public SerializableHashtable Albums = null;

        public SypSyncSite(){}

        public SypSyncSite(int SiteId) { this.siteID = SiteId; }

       

        public void AddAlbumBloc(int albumID, string Location)
        {
            SypSyncAlbum NewAlbum = new SypSyncAlbum();
            NewAlbum.syncFolder = Location;
            if (Albums == null)
                Albums = new SerializableHashtable();
            Albums.Add(albumID, NewAlbum);
        }

        public void RemoveAlbumBloc(int albumID)
        {
            if (Albums != null && Albums.ContainsKey(albumID))
            {
                Albums.Remove(albumID);
            }
        }

        public void AddPictureBloc(int albumID, string pictureLocation)
        {
            if (Albums != null && Albums.ContainsKey(albumID))
            {
                SypSyncAlbum currentAlbum = (SypSyncAlbum)Albums[albumID];
                if (currentAlbum != null)
                {
                    if (currentAlbum.Entities == null)
                        currentAlbum.Entities = new List<string>();
                    currentAlbum.Entities.Add(pictureLocation);
                }
            }
        }

        public void RemovePictureBloc(int albumID, string pictureLocation)
        {
            if (Albums != null && Albums.ContainsKey(albumID))
            {
                SypSyncAlbum currentAlbum = (SypSyncAlbum)Albums[albumID];

                if (currentAlbum != null && currentAlbum.Entities != null && currentAlbum.Entities.Contains(pictureLocation))
                {
                    currentAlbum.Entities.Remove(pictureLocation);
                }
            }
        }

        public bool PictureIsSynchronised(int albumID, string location)
        {
            if (Albums != null && Albums.ContainsKey(albumID))
            {
                SypSyncAlbum currentAlbum = (SypSyncAlbum)Albums[albumID];
                if (currentAlbum != null && currentAlbum.Entities != null && currentAlbum.Entities.Contains(location))
                    return true;
            }
            return false;
        }

        public string GetAlbumPath(int albumID)
        {
            if (Albums != null && Albums.ContainsKey(albumID))
            {
                SypSyncAlbum currentAlbum = (SypSyncAlbum)Albums[albumID];
                if (currentAlbum != null)
                    return currentAlbum.syncFolder;
            }
            return null;
        }
      


        public int GetPictureNb(int albumID)
        {
            if (Albums != null && Albums.ContainsKey(albumID))
            {
                SypSyncAlbum currentAlbum = (SypSyncAlbum)Albums[albumID];
                if (currentAlbum != null && currentAlbum.Entities != null)
                    return currentAlbum.Entities.Count;
            }
            return 0;
        }


    }
}
